* Replication file for the article "Am I Eligible to Register? Registration Rules, Eligibility Uncertainty, and Youth Voter Turnout" by Alexander Held

* The author does not have permission to share data from the voter files for California, New York and Pennsylvania. Data for these states is therefore not included in the replication datasets. As a result, the code and data do not allow to reproduce results for these three states or for pooled models that include any of these three states. The article uses the statistical software Stata 14.


* Set the working directory to the folder on your computer with the datasets
* cd "C:\Users\[AUTHOR]\Documents"


************
* FIGURE 1 *
************

* The following (optional) graphic scheme requires the installation of the gr0070 package from Bischof (2017)
* Bischof, Daniel. 2017. "New Graphic Schemes for Stata: plotplain and plottig." The Stata Journal 17(3): 748-759.
* set scheme plotplain
clear
set seed 1234567
set obs 360
gen birthdate=[_n]+11085
gen calendardate=string(birthdate, "%td")
gen turnout=45 if birthdate<11266
replace turnout=0 if birthdate>11265
gen days_ratio=(birthdate-11265)/180
replace turnout=turnout*rnormal(1,.03)
replace turnout=turnout-7 if birthdate>11237 & birthdate<11266
gen test=65

twoway (area test birthdate if birthdate==11085, fc(gs0) fi(inten10))(area test birthdate if birthdate>11085 & birthdate<11237, fc(gs0) fi(inten10))(area test birthdate if birthdate>11237 & birthdate<11265, fc(gs0) fi(inten10))(lpoly turnout birthdate if birthdate<11238, lcolor(black) lpattern(solid)) ///
	(lpoly turnout birthdate if birthdate>11237 & birthdate<11266, lcolor(black) lpattern(solid)) ///
	(lpoly turnout birthdate if birthdate>11265, lcolor(black) lpattern(solid)), ///
	yscale(range(0 65)) ylabel(0 "0%" 10 "10%" 20 "20%" 30 "30%" 40 ///
	"40%" 50 "50%" 60 "60%", angle(horizontal) labsize(medium) nogrid) xlabel(, nogrid) ///
	ytitle(Turnout, size(large)) xtitle(Date of birth, size(large)) xline(11265, lp(shortdash) lc(gs0)) ///
	xline(11237, lp(shortdash) lc(gs0)) ///
	xtitle(, margin(top)) xlabel(11085 "5/4/90" 11175 "8/4/90" 11265 "11/4/90" 11355 "2/4/91" 11445 "5/4/91", labsize(medium) valuelabel) ///
	title("(a) Expected", bexpand size(large)) legend(off)
gr_edit .plotregion1.AddTextBox added_text editor 20 11120
gr_edit .plotregion1.added_text[1].style.editstyle  size(large) editcopy
gr_edit .plotregion1.added_text[1].text.Arrpush Eligible in 2008
gr_edit .plotregion1.AddTextBox added_text editor 20 11300
gr_edit .plotregion1.added_text[2].style.editstyle  size(large) editcopy
gr_edit .plotregion1.added_text[2].text.Arrpush Ineligible in 2008
gr_edit .plotregion1.AddTextBox added_text editor 12 11253
gr_edit .plotregion1.added_text[3].style.editstyle  size(medium) editcopy
gr_edit .plotregion1.added_text[3]._set_orientation vertical
gr_edit .plotregion1.added_text[3].text.Arrpush Election Day
gr_edit .plotregion1.AddTextBox added_text editor 18 11225
gr_edit .plotregion1.added_text[4].style.editstyle  size(medium) editcopy
gr_edit .plotregion1.added_text[4]._set_orientation vertical
gr_edit .plotregion1.added_text[4].text.Arrpush Registration Deadline
graph save "Graph1a.gph", replace



use "data.dta", clear
replace rv08=-rv08
twoway (scatter turnout08 rv08, mcolor(gs10)) (lpolyci turnout08 rv08 if rv08>=-1 & rv08<-.1521, lp(solid) lcolor(black) ciplot(rline) alpattern(shortdash) deg(1)) ///
	(lpolyci turnout08 rv08 if rv08>=-.1521 & rv08<=0, lp(solid) lcolor(black) ciplot(rline) alpattern(shortdash)) ///
	(lpolyci turnout08 rv08 if rv08>0 & rv08<=1, lcolor(black) ciplot(rline)) ///
	if state=="FL" & rv08>-1 & rv08<1, ytitle(Turnout, size(large)) ///
	yscale(range(0 .6)) ylabel(0 "0%" .1 "10%" .2 "20%" .3 "30%" .4 "40%" .5 "50%" .6 "60%", ///
	labsize(medium) angle(horizontal) nogrid) xtitle(Date of Birth, size(large)) xlabel(, nogrid) ///
	xline(-.1521739, lc(black)) xline(0, lc(black)) xtitle(, margin(top)) xlabel(-1 "5/4/90" -.5 "8/4/90" 0 "11/4/90" .5 ///
	"2/4/91" 1 "5/4/91", labsize(medium) valuelabel) title("(b) Observed", bexpand size(large)) legend(off)
gr_edit .plotregion1.AddTextBox added_text editor .3 -.95
gr_edit .plotregion1.added_text[1].style.editstyle  size(large) editcopy
gr_edit .plotregion1.added_text[1].text.Arrpush Eligible in 2008
gr_edit .plotregion1.AddTextBox added_text editor .3 .2
gr_edit .plotregion1.added_text[2].style.editstyle  size(large) editcopy
gr_edit .plotregion1.added_text[2].text.Arrpush Ineligible in 2008
gr_edit .plotregion1.AddTextBox added_text editor .11 -.07
gr_edit .plotregion1.added_text[3].style.editstyle  size(medium) editcopy
gr_edit .plotregion1.added_text[3]._set_orientation vertical
gr_edit .plotregion1.added_text[3].text.Arrpush Election Day
gr_edit .plotregion1.AddTextBox added_text editor .16 -.233
gr_edit .plotregion1.added_text[4].style.editstyle  size(medium) editcopy
gr_edit .plotregion1.added_text[4]._set_orientation vertical
gr_edit .plotregion1.added_text[4].text.Arrpush Registration Deadline
graph save "Graph1b.gph", replace
replace rv08=-rv08

graph combine Graph1a.gph Graph1b.gph, ysize(2) altshrink
graph export "Fig1.pdf", as(pdf) replace
graph export "Fig1.eps", as(eps) replace




************
* FIGURE 2 *
************

use "data.dta", clear
gen birth_date=birthdate
format birth_date %td
gen dow=dow(birth_date)
gen voted08_adj=voted08
replace voted08_adj=. if dow==0 | dow==6

replace days_08 = days_08 - 28 if state=="FL"
replace days_08 = days_08 - 26 if state=="MO"
replace days_08 = days_08 - 29 if state=="RI"
replace days_08 = days_08 - 24 if state=="OK"

twoway (scatter voted08_adj days_08, sort msize(small) msymbol(circle_hollow) mcolor(black)) (lpolyci voted08_adj days_08 if days_08>-180 & days_08<=-30, lp(solid) lcolor(black) ciplot(rline) alpattern(shortdash)) (lpolyci voted08_adj days_08 if days_08>-30 & days_08<0, lp(solid) lcolor(black) bw(5) ciplot(rline) alpattern(shortdash)) (lpoly voted08_adj days_08 if days_08>0 & days_08<180, lcolor(black)) ///
if state=="RI" & days_08>-180 & days_08<180, ytitle(Votes, size(medium)) ylabel(, angle(horizontal) nogrid labsize(medium)) xtitle(Date of Birth, size(medium)) xline(-30, lc(gs12)) xline(0, lc(gs6)) xtitle(, margin(top)) xlabel(-153 "6/4/90" 0 "11/4/90" 151 "4/4/91", nogrid labsize(medium) valuelabel)  title("Rhode Island (30 days)", bexpand justification(left) size(large)) legend(off)
graph save "RI+.gph", replace
twoway (scatter voted08_adj days_08, sort msize(small) msymbol(circle_hollow) mcolor(black)) (lpolyci voted08_adj days_08 if days_08>-180 & days_08<=-29, lp(solid) lcolor(black) ciplot(rline) alpattern(shortdash)) (lpolyci voted08_adj days_08 if days_08>-29 & days_08<0, lp(solid) lcolor(black) bw(5) ciplot(rline) alpattern(shortdash)) (lpoly voted08_adj days_08 if days_08>0 & days_08<180, lcolor(black)) ///
if state=="FL" & days_08>-180 & days_08<180, ytitle(Votes, size(medium)) ylabel(, angle(horizontal) nogrid labsize(medium)) xtitle(Date of Birth, size(medium)) xline(-29, lc(gs12)) xline(0, lc(gs6)) xtitle(, margin(top)) xlabel(-153 "6/4/90" 0 "11/4/90" 151 "4/4/91", nogrid labsize(medium) valuelabel)  title("Florida (29 days)", bexpand justification(left) size(large)) legend(off)
graph save "FL+.gph", replace
twoway (scatter voted08_adj days_08, sort msize(small) msymbol(circle_hollow) mcolor(black)) (lpolyci voted08_adj days_08 if days_08>-180 & days_08<=-27, lp(solid) lcolor(black) ciplot(rline) alpattern(shortdash)) (lpolyci voted08_adj days_08 if days_08>-27 & days_08<0, lp(solid) lcolor(black) bw(5) ciplot(rline) alpattern(shortdash)) (lpoly voted08_adj days_08 if days_08>0 & days_08<180, lcolor(black)) ///
if state=="MO" & days_08>-180 & days_08<180, ytitle(Votes, size(medium)) ylabel(, angle(horizontal) nogrid labsize(medium)) xtitle(Date of Birth, size(medium)) xline(-27, lc(gs12)) xline(0, lc(gs6)) xtitle(, margin(top)) xlabel(-153 "6/4/90" 0 "11/4/90" 151 "4/4/91", nogrid labsize(medium) valuelabel)  title("Missouri (27 days)", bexpand justification(left) size(large)) legend(off)
graph save "MO+.gph", replace
twoway (scatter voted08_adj days_08, sort msize(small) msymbol(circle_hollow) mcolor(black)) (lpolyci voted08_adj days_08 if days_08>-180 & days_08<=-25, lp(solid) lcolor(black) ciplot(rline) alpattern(shortdash)) (lpolyci voted08_adj days_08 if days_08>-25 & days_08<0, lp(solid) lcolor(black) bw(5) ciplot(rline) alpattern(shortdash)) (lpoly voted08_adj days_08 if days_08>0 & days_08<180, lcolor(black)) ///
if state=="OK" & days_08>-180 & days_08<180, ytitle(Votes, size(medium)) ylabel(, angle(horizontal) nogrid labsize(medium)) xtitle(Date of Birth, size(medium)) xline(-25, lc(gs12)) xline(0, lc(gs6)) xtitle(, margin(top)) xlabel(-153 "6/4/90" 0 "11/4/90" 151 "4/4/91", nogrid labsize(medium) valuelabel)  title("Oklahoma (25 days)", bexpand justification(left) size(large)) legend(off)
graph save "OK+.gph", replace
graph combine RI+.gph FL+.gph MO+.gph OK+.gph, altshrink
graph export "Fig2.pdf", as(pdf) replace
graph export "Fig2.eps", as(eps) replace




************
* FIGURE 3 *
************

use "data.dta", clear

sort state
by state: egen t06 = mean(voted06) if days_06>=-10 & days_06<=-1
by state: egen treatment06 = max(t06)
by state: egen t08 = mean(voted08) if days_08>=-10 & days_08<=-1
by state: egen treatment08 = max(t08)
by state: egen t10 = mean(voted10) if days_10>=-10 & days_10<=-1
by state: egen treatment10 = max(t10)
by state: egen t12 = mean(voted12) if days_12>=-10 & days_12<=-1
by state: egen treatment12 = max(t12)
by state: egen t14 = mean(voted14) if days_14>=-10 & days_14<=-1
by state: egen treatment14 = max(t14)
by state: egen t16 = mean(voted16) if days_16>=-10 & days_16<=-1
by state: egen treatment16 = max(t16)
by state: egen t18 = mean(voted18) if days_18>=-10 & days_18<=-1
by state: egen treatment18 = max(t18)
drop t06 t08 t10 t12 t14 t16 t18

gen regdl = 0
replace regdl = 1 if days_08 >= 0

sort state birthdate
replace voted06lag = voted06lag/treatment06
replace voted08lag = voted08lag/treatment08
replace voted10lag = voted10lag/treatment10
replace voted12lag = voted12lag/treatment12
replace voted14lag = voted14lag/treatment14
replace voted16lag = voted16lag/treatment16
replace voted18lag = voted18lag/treatment18

replace voted06 = voted06/treatment06*100
replace voted08 = voted08/treatment08*100
replace voted10 = voted10/treatment10*100
replace voted12 = voted12/treatment12*100
replace voted14 = voted14/treatment14*100
replace voted16 = voted16/treatment16*100
replace voted18 = voted18/treatment18*100

gen tar = regdl if state=="AR"
gen tco = regdl if state=="CO"
gen tfl = regdl if state=="FL"
gen til = regdl if state=="IL"
gen tky = regdl if state=="KY"
gen tmo = regdl if state=="MO"
gen tmt = regdl if state=="MT"
gen toh = regdl if state=="OH"
gen tpa = regdl if state=="PA"
gen ttx = regdl if state=="TX"
gen tri = regdl if state=="RI"
gen tct = regdl if state=="CT"
gen tia = regdl if state=="IA"
gen tca = regdl if state=="CA"
gen tnj = regdl if state=="NJ"
gen tnv = regdl if state=="NV"
gen tor = regdl if state=="OR"
gen tny = regdl if state=="NY"
gen tok = regdl if state=="OK"

recode tar tco tfl til tky tmo tmt toh tpa ttx tri tct tia tca tnj ///
	tnv tor tny tok (. = 0)

regress voted08 tar voted08lag if (days_08>=-10 & days_08<=9) & state=="AR", robust
estimates store AR
regress voted08 tco voted08lag if (days_08>=-10 & days_08<=9) & state=="CO", robust
estimates store CO
regress voted08 tfl voted08lag if (days_08>=-10 & days_08<=9) & state=="FL", robust
estimates store FL
regress voted08 til voted08lag if (days_08>=-10 & days_08<=9) & state=="IL", robust
estimates store IL
regress voted08 tky voted08lag if (days_08>=-10 & days_08<=9) & state=="KY", robust
estimates store KY
regress voted08 tmo voted08lag if (days_08>=-10 & days_08<=9) & state=="MO", robust
estimates store MO
regress voted08 tmt voted08lag if (days_08>=-10 & days_08<=9) & state=="MT", robust
estimates store MT
regress voted08 toh voted08lag if (days_08>=-10 & days_08<=9) & state=="OH", robust
estimates store OH
*regress voted08 tpa voted08lag if (days_08>=-10 & days_08<=9) & state=="PA", robust
*estimates store PA
regress voted08 ttx voted08lag if (days_08>=-10 & days_08<=9) & state=="TX", robust
estimates store TX
regress voted08 tri voted08lag if (days_08>=-10 & days_08<=9) & state=="RI", robust
estimates store RI
regress voted08 tct voted08lag if (days_08>=-10 & days_08<=9) & state=="CT", robust
estimates store CT
regress voted08 tia voted08lag if (days_08>=-10 & days_08<=9) & state=="IA", robust
estimates store IA
*regress voted08 tca voted08lag if (days_08>=-10 & days_08<=9) & state=="CA", robust
*estimates store CA
regress voted08 tnj voted08lag if (days_08>=-10 & days_08<=9) & state=="NJ", robust
estimates store NJ
regress voted08 tnv voted08lag if (days_08>=-10 & days_08<=9) & state=="NV", robust
estimates store NV
regress voted08 tor voted08lag if (days_08>=-10 & days_08<=9) & state=="OR", robust
estimates store OR
*regress voted08 tny voted08lag if (days_08>=-10 & days_08<=9) & state=="NY", robust
*estimates store NY
regress voted08 tok voted08lag if (days_08>=-10 & days_08<=9) & state=="OK", robust
estimates store OK

*regress voted08 regdl voted08lag if (days_08>=-10 & days_08<=9) & (state=="AR" | state=="CO" | state=="FL" | state=="IL" | state=="KY" | state=="MO" | state=="NY" | state=="OH" | state=="OK" | state=="PA" | state=="RI" | state=="TX"), vce(cluster state)
*estimates store pooled1

*regress voted08 regdl voted08lag if (days_08>=-10 & days_08<=9) & (state=="CA" | state=="CT" | state=="IA" | state=="MT" | state=="NV" | state=="NJ" | state=="OR"), vce(cluster state)
*estimates store pooled2

coefplot (AR \ CO \ FL \ IL \ KY \ MO \ OH \ OK \ RI \ TX), ///
	keep(tar tco tfl til tky tmo tmt toh tpa ttx tri tct tia tca tnj ///
	tnv tor tny tok regdl) xline(0) coeflabels(tar="AR" tco="CO" tfl="FL" til="IL" tky="KY" /// 
	tmo="MO" tmt="MT" toh="OH" tpa="PA" ttx="TX" tri="RI" tct="CT" tia="IA" tca="CA" tnj="NJ" /// 
	tnv="NV" tor="OR" tny="NY" tok="OK" regdl="Pooled") xtitle("Estimate Decrease in %", size(medium))   ///
	xscale(range(-40 20))  xlabel(-40 "-40" -20 "-20" 0 "0"  ///
	20 "20", angle(horizontal)) xtick(-40(20)20) ///
	title("2008 Presidential Election", size(medlarge)) grid(none)
graph save "Figure3a.gph", replace
coefplot (CT \ IA \ MT \ NV \ NJ \ OR), ///
	keep(tar tco tfl til tky tmo tmt toh tpa ttx tri tct tia tca tnj ///
	tnv tor tny tok regdl) xline(0) coeflabels(tar="AR" tco="CO" tfl="FL" til="IL" tky="KY" /// 
	tmo="MO" tmt="MT" toh="OH" tpa="PA" ttx="TX" tri="RI" tct="CT" tia="IA" tca="CA" tnj="NJ" /// 
	tnv="NV" tor="OR" tny="NY" tok="OK" regdl="Pooled") xtitle("Estimate Decrease in %", size(medium))   ///
	xscale(range(-40 20))  xlabel(-40 "-40" -20 "-20" 0 "0"  ///
	20 "20", angle(horizontal)) xtick(-40(20)20) ///
	title("2008 Presidential Election", size(medlarge)) grid(none)
graph save "Figure3b.gph", replace



drop regdl
gen regdl = 0
replace regdl = 1 if days_12 >= 0
replace tar = regdl if state=="AR"
replace tco = regdl if state=="CO"
replace tfl = regdl if state=="FL"
replace til = regdl if state=="IL"
replace tky = regdl if state=="KY"
replace tmo = regdl if state=="MO"
replace tmt = regdl if state=="MT"
replace toh = regdl if state=="OH"
replace tpa = regdl if state=="PA"
replace ttx = regdl if state=="TX"
replace tri = regdl if state=="RI"
replace tct = regdl if state=="CT"
replace tia = regdl if state=="IA"
replace tca = regdl if state=="CA"
replace tnj = regdl if state=="NJ"
replace tnv = regdl if state=="NV"
replace tor = regdl if state=="OR"
replace tny = regdl if state=="NY"
replace tok = regdl if state=="OK"
recode tar tco tfl til tky tmo tmt toh tpa ttx tri tct tia tca tnj ///
	tnv tor tny tok (. = 0)

estimates clear

regress voted12 tar voted12lag if (days_12>=-10 & days_12<=9) & state=="AR", robust
estimates store AR
regress voted12 tfl voted12lag if (days_12>=-10 & days_12<=9) & state=="FL", robust
estimates store FL
regress voted12 til voted12lag if (days_12>=-10 & days_12<=9) & state=="IL", robust
estimates store IL
regress voted12 tky voted12lag if (days_12>=-10 & days_12<=9) & state=="KY", robust
estimates store KY
regress voted12 tmo voted12lag if (days_12>=-10 & days_12<=9) & state=="MO", robust
estimates store MO
regress voted12 tmt voted12lag if (days_12>=-10 & days_12<=9) & state=="MT", robust
estimates store MT
regress voted12 toh voted12lag if (days_12>=-10 & days_12<=9) & state=="OH", robust
estimates store OH
*regress voted12 tpa voted12lag if (days_12>=-10 & days_12<=9) & state=="PA", robust
*estimates store PA
regress voted12 ttx voted12lag if (days_12>=-10 & days_12<=9) & state=="TX", robust
estimates store TX
regress voted12 tri voted12lag if (days_12>=-10 & days_12<=9) & state=="RI", robust
estimates store RI
regress voted12 tct voted12lag if (days_12>=-10 & days_12<=9) & state=="CT", robust
estimates store CT
regress voted12 tia voted12lag if (days_12>=-10 & days_12<=9) & state=="IA", robust
estimates store IA
*regress voted12 tca voted12lag if (days_12>=-10 & days_12<=9) & state=="CA", robust
*estimates store CA
regress voted12 tnj voted12lag if (days_12>=-10 & days_12<=9) & state=="NJ", robust
estimates store NJ
regress voted12 tnv voted12lag if (days_12>=-10 & days_12<=9) & state=="NV", robust
estimates store NV
regress voted12 tor voted12lag if (days_12>=-10 & days_12<=9) & state=="OR", robust
estimates store OR
*regress voted12 tny voted12lag if (days_12>=-10 & days_12<=9) & state=="NY", robust
*estimates store NY
regress voted12 tok voted12lag if (days_12>=-10 & days_12<=9) & state=="OK", robust
estimates store OK

*regress voted12 regdl voted12lag if (days_12>=-10 & days_12<=9) & (state=="AR" | state=="FL" | state=="IL" | state=="KY" | state=="MO" | state=="NY" | state=="OH" | state=="OK" | state=="PA" | state=="RI" | state=="TX"), vce(cluster state)
*estimates store pooled1

*regress voted12 regdl voted12lag if (days_12>=-10 & days_12<=9) & (state=="CA" | state=="CT" | state=="IA" | state=="MT" | state=="NV" | state=="NJ" | state=="OR"), vce(cluster state)
*estimates store pooled2

coefplot (AR \ FL \ IL \ KY \ MO \ OH \ OK \ RI \ TX), ///
	keep(tar tfl til tky tmo tmt toh tpa ttx tri tct tia tca tnj ///
	tnv tor tny tok regdl) xline(0) coeflabels(tar="AR" tfl="FL" til="IL" tky="KY" /// 
	tmo="MO" tmt="MT" toh="OH" tpa="PA" ttx="TX" tri="RI" tct="CT" tia="IA" tca="CA" tnj="NJ" /// 
	tnv="NV" tor="OR" tny="NY" tok="OK" regdl="Pooled") xtitle("Estimate Decrease in %", size(medium))  ///
	xscale(range(-40 20))  xlabel(-40 "-40" -20 "-20" 0 "0"  ///
	20 "20", angle(horizontal)) xtick(-40(20)20) ///
	title("2012 Presidential Election", size(medlarge)) grid(none)
graph save "Figure3c.gph", replace
coefplot (CT \ IA \ MT \ NV \ NJ \ OR), ///
	keep(tar tfl til tky tmo tmt toh tpa ttx tri tct tia tca tnj ///
	tnv tor tny tok regdl) xline(0) coeflabels(tar="AR" tfl="FL" til="IL" tky="KY" /// 
	tmo="MO" tmt="MT" toh="OH" tpa="PA" ttx="TX" tri="RI" tct="CT" tia="IA" tca="CA" tnj="NJ" /// 
	tnv="NV" tor="OR" tny="NY" tok="OK" regdl="Pooled") xtitle("Estimate Decrease in %", size(medium))  ///
	xscale(range(-40 20))  xlabel(-40 "-40" -20 "-20" 0 "0"  ///
	20 "20", angle(horizontal)) xtick(-40(20)20) ///
	title("2012 Presidential Election", size(medlarge)) grid(none)
graph save "Figure3d.gph", replace



drop regdl
gen regdl = 0
replace regdl = 1 if days_16 >= 0
replace tar = regdl if state=="AR"
replace tco = regdl if state=="CO"
replace tfl = regdl if state=="FL"
replace til = regdl if state=="IL"
replace tky = regdl if state=="KY"
replace tmo = regdl if state=="MO"
replace tmt = regdl if state=="MT"
replace toh = regdl if state=="OH"
replace tpa = regdl if state=="PA"
replace ttx = regdl if state=="TX"
replace tri = regdl if state=="RI"
replace tct = regdl if state=="CT"
replace tia = regdl if state=="IA"
replace tca = regdl if state=="CA"
replace tnj = regdl if state=="NJ"
replace tnv = regdl if state=="NV"
replace tor = regdl if state=="OR"
replace tny = regdl if state=="NY"
replace tok = regdl if state=="OK"
recode tar tco tfl til tky tmo tmt toh tpa ttx tri tct tia tca tnj ///
	tnv tor tny tok (. = 0)

estimates clear

regress voted16 tfl voted16lag if (days_16>=-10 & days_16<=9) & state=="FL", robust
estimates store FL
regress voted16 toh voted16lag if (days_16>=-10 & days_16<=9) & state=="OH", robust
estimates store OH
*regress voted16 tpa voted16lag if (days_16>=-10 & days_16<=9) & state=="PA", robust
*estimates store PA
* Texas without lagged DV and more narrow 7-day window due to missing data
regress voted16 ttx if (days_16>=-7 & days_16<=6) & state=="TX", robust
estimates store TX
*regress voted16 tca voted16lag if (days_16>=-10 & days_16<=9) & state=="CA", robust
*estimates store CA
*regress voted16 tny voted16lag if (days_16>=-10 & days_16<=9) & state=="NY", robust
*estimates store NY
regress voted16 tok voted16lag if (days_16>=-10 & days_16<=9) & state=="OK", robust
estimates store OK

*regress voted16 regdl if (days_16>=-7 & days_16<=6) & (state=="FL" | state=="NY" | state=="OH" | state=="OK" | state=="PA" | state=="TX"), vce(cluster state)
*estimates store pooled1a

* The following model does not include Texas due to missing data (no lagged DV)
gen regdl1b = regdl
*regress voted16 regdl1b voted16lag if (days_16>=-10 & days_16<=9) & (state=="FL" | state=="NY" | state=="OH" | state=="OK" | state=="PA"), vce(cluster state)
*estimates store pooled1b

coefplot (FL \ OH \ OK \ TX), ///
	keep(tfl toh tpa ttx tca tny tok regdl regdl1b) xline(0) coeflabels(tfl="FL" /// 
	toh="OH" tpa="PA" ttx="TX" tca="CA" /// 
	tny="NY" tok="OK" regdl="Pooled" regdl1b="Pooled w/o Texas") xtitle("Estimate Decrease in %", size(medium))  ///
	xscale(range(-40 20))  xlabel(-40 "-40" -20 "-20" 0 "0"  ///
	20 "20", angle(horizontal)) xtick(-40(20)20) ///
	title("2016 Presidential Election", size(medlarge)) grid(none)
graph save "Figure3e.gph", replace
*coefplot, ///
*	keep(tfl toh tpa ttx tca tny tok) xline(0) coeflabels(tfl="FL" /// 
*	toh="OH" tpa="PA" ttx="TX" tca="CA" /// 
*	tny="NY" tok="OK") xtitle("Estimate Decrease in %", size(medium))  ///
*	xscale(range(-40 20))  xlabel(-40 "-40" -20 "-20" 0 "0"  ///
*	20 "20", angle(horizontal)) xtick(-40(20)20) ///
*	title("2016 Presidential Election", size(medlarge)) grid(none)
*graph save "Figure3f.gph", replace

graph combine Figure3a.gph Figure3c.gph Figure3e.gph, title("Earlier Registration Deadline and No SDR", size(medium)) name(gr1, replace) col(3)
graph combine Figure3b.gph Figure3d.gph, title("Later Registration Deadline and/or SDR", size(medium)) name(gr2, replace) col(2)
graph combine gr1 gr2, row(2)
graph export "Fig3.pdf", as(pdf) replace
graph export "Fig3.eps", as(eps) replace




***********
* TABLE 1 *
***********

use "data.dta", clear

sort state
by state: egen t06 = mean(voted06) if days_06>=-10 & days_06<=-1
by state: egen treatment06 = max(t06)
by state: egen t08 = mean(voted08) if days_08>=-10 & days_08<=-1
by state: egen treatment08 = max(t08)
by state: egen t10 = mean(voted10) if days_10>=-10 & days_10<=-1
by state: egen treatment10 = max(t10)
by state: egen t12 = mean(voted12) if days_12>=-10 & days_12<=-1
by state: egen treatment12 = max(t12)
by state: egen t14 = mean(voted14) if days_14>=-10 & days_14<=-1
by state: egen treatment14 = max(t14)
by state: egen t16 = mean(voted16) if days_16>=-10 & days_16<=-1
by state: egen treatment16 = max(t16)
by state: egen t18 = mean(voted18) if days_18>=-10 & days_18<=-1
by state: egen treatment18 = max(t18)
drop t06 t08 t10 t12 t14 t16 t18

gen regdl = 0
replace regdl = 1 if days_08 >= 0

sort state birthdate
replace voted06lag = voted06lag/treatment06
replace voted08lag = voted08lag/treatment08
replace voted10lag = voted10lag/treatment10
replace voted12lag = voted12lag/treatment12
replace voted14lag = voted14lag/treatment14
replace voted16lag = voted16lag/treatment16
replace voted18lag = voted18lag/treatment18

replace voted06 = voted06/treatment06*100
replace voted08 = voted08/treatment08*100
replace voted10 = voted10/treatment10*100
replace voted12 = voted12/treatment12*100
replace voted14 = voted14/treatment14*100
replace voted16 = voted16/treatment16*100
replace voted18 = voted18/treatment18*100

replace voted08=voted08/100

gen sdr=0
replace sdr=1 if state=="IA" | state=="MT"
gen regdlXsdr=regdl*sdr
gen regdays=.
replace regdays=29 if state=="AR"
replace regdays=15 if state=="CA"
replace regdays=29 if state=="CO"
replace regdays=14 if state=="CT"
replace regdays=29 if state=="FL"
replace regdays=10 if state=="IA"
replace regdays=28 if state=="IL"
replace regdays=29 if state=="KY"
replace regdays=27 if state=="MO"
replace regdays=29 if state=="MT"
replace regdays=21 if state=="NJ"
replace regdays=21 if state=="NV"
replace regdays=25 if state=="NY"
replace regdays=29 if state=="OH"
replace regdays=25 if state=="OK"
replace regdays=21 if state=="OR"
replace regdays=29 if state=="PA"
replace regdays=30 if state=="RI"
replace regdays=29 if state=="TX"
gen regdlXregdays=regdl*regdays
gen misinf=0
replace misinf=1 if state=="FL" | state=="OK" | state=="TX"
gen regdlXmisinf=regdl*misinf

* Note that results in the article are different from the following regressions because they include data for CA, NY and PA.

* Column 1
regress voted08 regdl sdr regdlXsdr voted08lag if (days_08>=-10 & days_08<=9), vce(cluster state)
* Column 3
regress voted08 regdl regdays regdlXregdays voted08lag if (days_08>=-10 & days_08<=9), vce(cluster state)
* Column 5
regress voted08 regdl misinf regdlXmisinf voted08lag if (days_08>=-10 & days_08<=9), vce(cluster state)
* Column 7
regress voted08 regdl sdr regdlXsdr regdays regdlXregdays misinf regdlXmisinf voted08lag if (days_08>=-10 & days_08<=9), vce(cluster state)

replace voted08=voted08*100
drop regdl regdays regdlXregdays regdlXsdr regdlXmisinf
gen regdl = 0
replace regdl = 1 if days_12 >= 0
replace voted12=voted12/100
gen regdlXsdr=regdl*sdr
gen regdays=.
replace regdays=28 if state=="AR"
replace regdays=15 if state=="CA"
replace regdays=28 if state=="CO"
replace regdays=14 if state=="CT"
replace regdays=28 if state=="FL"
replace regdays=10 if state=="IA"
replace regdays=28 if state=="IL"
replace regdays=28 if state=="KY"
replace regdays=27 if state=="MO"
replace regdays=28 if state=="MT"
replace regdays=21 if state=="NJ"
replace regdays=21 if state=="NV"
replace regdays=25 if state=="NY"
replace regdays=28 if state=="OH"
replace regdays=25 if state=="OK"
replace regdays=21 if state=="OR"
replace regdays=28 if state=="PA"
replace regdays=30 if state=="RI"
replace regdays=28 if state=="TX"
gen regdlXregdays=regdl*regdays
gen regdlXmisinf=regdl*misinf

* Note that results in the article will be different from the following regressions because they include data for CA, NY and PA.

* Column 2
regress voted12 regdl sdr regdlXsdr voted12lag if (days_12>=-10 & days_12<=9), vce(cluster state)
* Column 4
regress voted12 regdl regdays regdlXregdays voted12lag if (days_12>=-10 & days_12<=9), vce(cluster state)
* Column 6
regress voted12 regdl misinf regdlXmisinf voted12lag if (days_12>=-10 & days_12<=9), vce(cluster state)
* Column 8
regress voted12 regdl sdr regdlXsdr regdays regdlXregdays misinf regdlXmisinf voted12lag if (days_12>=-10 & days_12<=9), vce(cluster state)
replace voted12=voted12*100




************
* FIGURE 4 *
************

use "data.dta", clear

encode state, gen(state2)
tab state2, gen(sdum)

gen regdl = 0
replace regdl = 1 if days_08 >= 0

gen var = voted08 * sdum1
gen vco = voted08 * sdum2
gen vfl = voted08 * sdum4
gen vil = voted08 * sdum6
gen vky = voted08 * sdum7
gen vmo = voted08 * sdum8
gen vmt = voted08 * sdum9
gen voh = voted08 * sdum12
gen vtx = voted08 * sdum16
gen vri = voted08 * sdum15
gen vct = voted08 * sdum3
gen via = voted08 * sdum5
gen vnj = voted08 * sdum10
gen vnv = voted08 * sdum11
gen vor = voted08 * sdum14
gen vok = voted08 * sdum13

ivregress 2sls voted12 (var = regdl) voted12lag if  state=="AR" & (days_08>=-10 & days_08<=9), robust first
estimates store A
ivregress 2sls voted12 (vfl = regdl) voted12lag if  state=="FL" & (days_08>=-10 & days_08<=9), robust first
estimates store B
ivregress 2sls voted12 (vil = regdl) voted12lag if  state=="IL" & (days_08>=-10 & days_08<=9), robust first
estimates store C
ivregress 2sls voted12 (vmo = regdl) voted12lag if  state=="MO" & (days_08>=-10 & days_08<=9), robust first
estimates store D
*ivregress 2sls voted12 (vpa = regdl) voted12lag if  state=="PA" & (days_08>=-10 & days_08<=9), robust first
*estimates store E
ivregress 2sls voted12 (vtx = regdl) voted12lag if  state=="TX" & (days_08>=-10 & days_08<=9), robust first
estimates store F
ivregress 2sls voted12 (vri = regdl) voted12lag if  state=="RI" & (days_08>=-10 & days_08<=9), robust first
estimates store I
ivregress 2sls voted12 (vok = regdl) voted12lag if  state=="OK" & (days_08>=-10 & days_08<=9), robust first
estimates store G

*ivregress 2sls voted12 (voted08 = regdl) voted12lag if  (state=="AR" | state=="FL" | state=="IL" | state=="MO" | state=="OK" | state=="PA" | state=="TX" | state=="RI") & (days_08>=-10 & days_08<=9), vce(cluster state) first
*estimates store pooled1

coefplot (A \B \C \D \G \I \F), keep(var vfl vil vmo vok vpa vri vtx voted08) ///
xline(0) coeflabels(var="Arkansas" vfl="Florida" vil="Illinois" vmo="Missouri" vok="Oklahoma" vpa="Pennsylvania" vtx="Texas" vri="Rhode Island" voted08="Pooled", labsize(large)) ///
xtitle("Downstream Non-Voting", size(large)) xlabel(.0 (.25) .75,labsize(large)) ///
xscale(range(.0 .75)) title("(a) 2012 Presidential Election", size(vlarge)) grid(none)
graph save "Figure4a.gph", replace

ivregress 2sls voted16 (vfl = regdl) voted16lag if  state=="FL" & (days_08>=-10 & days_08<=9), robust first
estimates store J
*ivregress 2sls voted16 (vpa = regdl) voted16lag if  state=="PA" & (days_08>=-10 & days_08<=9), robust first
*estimates store K
ivregress 2sls voted16 (vtx = regdl) if  state=="TX" & (days_08>=-7 & days_08<=6), robust first
estimates store L
ivregress 2sls voted16 (vok = regdl) voted16lag if  state=="OK" & (days_08>=-10 & days_08<=9), robust first
estimates store M

gen voted08p2a = voted08
gen voted08p2b = voted08
gen voted08p2c = voted08
*ivregress 2sls voted16 (voted08p2a = regdl) if  (state=="FL" | state=="OK" | state=="PA" | state=="TX") & (days_08>=-7 & days_08<=6), vce(cluster state) first
*estimates store pooled2a
*ivregress 2sls voted16 (voted08p2b = regdl) voted16lag if  (state=="FL" | state=="OK" | state=="PA") & (days_08>=-10 & days_08<=9), vce(cluster state) first
*estimates store pooled2b
ivregress 2sls voted16 (voted08p2c = regdl) if  (state=="FL" | state=="OK" | state=="TX") & (days_08>=-7 & days_08<=6), vce(cluster state) first
estimates store pooled2c

coefplot (J \M \L \pooled2c), keep(vfl vok vpa vtx voted08p2a voted08p2b voted08p2c) xline(0) ///
coeflabels(vfl="Florida" vok="Oklahoma" vpa="Pennsylvania" vtx="Texas" voted08p2a="Pooled" voted08p2b="Pooled w/o Texas" voted08p2c="Pooled w/o PA", labsize(large)) ///
xtitle("Downstream Non-Voting", size(large)) xlabel(.0 (.25) .75,labsize(large)) ///
xscale(range(.0 .75)) title("(b) 2016 Presidential Election", size(vlarge)) grid(none)
*groups(v08fl v08tx v08il="Large Drop" v08*="Small Drop", labsize(large))
graph save "Figure4b.gph", replace

ivregress 2sls voted10 (var = regdl) voted10lag if  state=="AR" & (days_08>=-10 & days_08<=9), robust first
estimates store N
ivregress 2sls voted10 (vfl = regdl) voted10lag if  state=="FL" & (days_08>=-10 & days_08<=9), robust first
estimates store O
ivregress 2sls voted10 (vil = regdl) voted10lag if  state=="IL" & (days_08>=-10 & days_08<=9), robust first
estimates store P
ivregress 2sls voted10 (vmo = regdl) voted10lag if  state=="MO" & (days_08>=-10 & days_08<=9), robust first
estimates store Q
*ivregress 2sls voted10 (vpa = regdl) voted10lag if  state=="PA" & (days_08>=-10 & days_08<=9), robust first
*estimates store R
ivregress 2sls voted10 (vtx = regdl) voted10lag if  state=="TX" & (days_08>=-10 & days_08<=9), robust first
estimates store S
ivregress 2sls voted10 (vri = regdl) voted10lag if  state=="RI" & (days_08>=-10 & days_08<=9), robust first
estimates store T
ivregress 2sls voted10 (vok = regdl) voted10lag if  state=="OK" & (days_08>=-10 & days_08<=9), robust first
estimates store U

*ivregress 2sls voted10 (voted08 = regdl) voted10lag if  (state=="AR" | state=="FL" | state=="IL" | state=="MO" | state=="OK" | state=="PA" | state=="TX" | state=="RI") & (days_08>=-10 & days_08<=9), vce(cluster state) first
*estimates store pooled3

coefplot (N \O \P \Q \U \T \S), keep(var vfl vil vmo vok vpa vri vtx voted08) ///
xline(0) coeflabels(var="Arkansas" vfl="Florida" vil="Illinois" vmo="Missouri" vok="Oklahoma" vpa="Pennsylvania" vtx="Texas" vri="Rhode Island" voted08="Pooled", labsize(large)) ///
xtitle("Downstream Non-Voting", size(large)) xlabel(.0 (.25) .75,labsize(large)) ///
xscale(range(.0 .75)) title("(c) 2010 Midterm Elections", size(vlarge)) grid(none)
graph save "Figure4c.gph", replace

ivregress 2sls voted14 (vfl = regdl) voted14lag if  state=="FL" & (days_08>=-10 & days_08<=9), robust first
estimates store V
*ivregress 2sls voted14 (vpa = regdl) voted14lag if  state=="PA" & (days_08>=-10 & days_08<=9), robust first
*estimates store W
ivregress 2sls voted14 (vtx = regdl) voted14lag if  state=="TX" & (days_08>=-10 & days_08<=9), robust first
estimates store X
ivregress 2sls voted14 (vok = regdl) voted14lag if  state=="OK" & (days_08>=-10 & days_08<=9), robust first
estimates store Y

*ivregress 2sls voted14 (voted08 = regdl) voted14lag if  (state=="FL" | state=="OK" | state=="PA" | state=="TX") & (days_08>=-10 & days_08<=9), vce(cluster state) first
*estimates store pooled4

coefplot (V \Y \X), keep(vfl vok vpa vtx voted08) xline(0) ///
coeflabels(vfl="Florida" vok="Oklahoma" vpa="Pennsylvania" vtx="Texas" voted08="Pooled", labsize(large)) ///
xtitle("Downstream Non-Voting", size(large)) xlabel(.0 (.25) .75,labsize(large)) ///
xscale(range(.0 .75)) title("(d) 2014 Midterm Elections", size(vlarge)) grid(none)
graph save "Figure4d.gph", replace

graph combine Figure4a.gph Figure4b.gph Figure4c.gph Figure4d.gph, ysize(4) altshrink
graph export "Fig4.pdf", as(pdf) replace
graph export "Fig4.eps", as(eps) replace





